package FourArithmeticOperations;

import java.util.AbstractList;
import java.util.ArrayList;

/**
 * Created by dell on 2017/9/25.
 */
public class Array{
    ArrayList list= new ArrayList();
    public boolean add(String s){
        return false;
    }
    public boolean remove(String s){
        return false;
    }
    public boolean isEmpty(){
        return false;
    }
    public static void selectionSort(Comparable[] data){
        int min;
        for (int index = 0;index<data.length-1;index++){
            min = index;
            for (int scan = index+1;scan<data.length;scan++)
                if (data[scan].compareTo(data[min])<0)
                    min = scan;
            swap(data,min,index);
        }
    }
    private static void swap(Comparable[] data, int index1, int index2) {
        Comparable temp = data[index1];
        data[index1] = data[index2];
        data[index2]= temp;
    }
    public static void bubbleSort (Comparable[] data) {
        int position,scan;
        for (position = data.length-1;position>=0;position--){
            for (scan = 0;scan<=position-1;scan++)
                if (data[scan].compareTo(data[scan+1])>0)
                    swap(data,scan,scan+1);
        }
    }
}
